<%-- 
    Document   : see_posts
    Created on : 30 May, 2012, 4:57:09 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="innertable.css">
        <title>Online College Magazine</title>
    </head>
    <body>
        <%
            String username = (String) session.getAttribute("username");
            out.println(username);

            Connection con = null;
            PreparedStatement pstmt = null;
            ResultSet rs = null;

            try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                pstmt = con.prepareStatement("select *from posts where postedby=?");
                pstmt.setString(1, username);
                rs = pstmt.executeQuery();
                while (rs.next()) {
                    
                    %>
                    
                    <table>
                        <col width="50" />
                        
                        <tr>
                            <td>
                                Post Type
                            </td>
                            <td>
                                <%=rs.getString(2)%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Subject
                            </td>
                            <td>
                                <%=rs.getString(3)%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Post
                            </td>
                            <td>
                                <%=rs.getString(4)%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Posted on
                            </td>
                            <td>
                                <%=rs.getString(5)%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Posted By 
                            </td>
                            <td>
                                <%=rs.getString(8)%>
                            </td>
                        </tr>
                    </table>
                                        <%
                }
            } catch (Exception e) {
                response.sendError(521, e.getMessage());
                e.printStackTrace();
            }
        %>
    </body>
</html>
